package org.dromara.chicken.service.impl;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.chicken.domain.ChickenFeedOutInfo;
import org.dromara.chicken.mapper.ChickenFeedOutInfoMapper;
import org.dromara.chicken.service.IChickenFeedOutInfoService;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * 鸡饲料投放Service业务层处理
 *
 * @author Mr Lei
 * @date 2024-05-29
 */
@RequiredArgsConstructor
@Service
public class ChickenFeedOutInfoServiceImpl implements IChickenFeedOutInfoService {

    private final ChickenFeedOutInfoMapper baseMapper;

/*新增*/
    @Override
    public Boolean insertByBo(ChickenFeedOutInfo bo){
        ChickenFeedOutInfo add = MapstructUtils.convert(bo, ChickenFeedOutInfo.class);
        validEntityBeforeSave(add);
        return true;
    }
    @Override
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
//        LambdaQueryWrapper<Object> wrapper = new LambdaQueryWrapper<>();
        if(isValid){
            //TODO 业务校验
        }
       return  baseMapper.deleteBatchIds(ids) >0;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ChickenFeedOutInfo entity) {
        //TODO 做一些数据校验,如唯一约束
    }
}
